{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "#r \"nuget: MiniExcel\"\n",
    "\n",
    "using System.IO;\n",
    "using MiniExcelLibs;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "using MiniExcelLibs.OpenXml;\n",
    "using System.Diagnostics;\n",
    "\n",
    "class Data\n",
    "{\n",
    "    public string Column1 { get; set; }\n",
    "    public int Column2 { get; set; }\n",
    "}\n",
    "\n",
    "var data = new{\n",
    "    values = new[]{\n",
    "        new Data() { Column1 = \"MiniExcel\", Column2 = 1 },\n",
    "        new Data() { Column1 = \"Github\", Column2 = 2}\n",
    "    }\n",
    "};\n",
    "\n",
    "MiniExcel.SaveAsByTemplate(\"Template1.xlsx\", \"Template.xlsx\", data);\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "Stopwatch sw = Stopwatch.StartNew();\n",
    "List<Data> data = MiniExcel.Query<Data>(path).ToList();\n",
    "Data values1 = new Data { Column1 = $\"{DateTime.Now.ToString(\"HH:mm:ss\")}\", Column2 = 1 };\n",
    "for(int i = 0; i < 10000; i++)\n",
    "{\n",
    "    data.Add(values1);\n",
    "}\n",
    "data.Count.Display();\n",
    "MiniExcel.SaveAs(path, data, configuration: config, overwriteFile:true);\n",
    "Console.WriteLine($\"Elapsed time: {sw.ElapsedMilliseconds}ms\");"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "languageName": "csharp",
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
